import React, { Component } from 'react';
import { Modal, Button, message, Form, Row, Col, Input, Checkbox, Icon, InputNumber, Popconfirm, Switch } from 'antd';

const FormItem = Form.Item;
import { toJS } from 'mobx';
import equal from 'deep-equal';
import { WeaDialog, WeaRightMenu, WeaInput, WeaSearchGroup, WeaTools, WeaFormItem, WeaNewScroll } from 'ecCom';
import CustomerContact from '../public/CustomerContact';
import RemindSetModal from '../dialog/setRemindDialog';
import { WeaLocaleProvider } from 'ecCom';

const getLabel = WeaLocaleProvider.getLabel;

class CustomerContactDialog extends Component {
  constructor(props) {
    super(props);
    this.state = {
      visible: false,
      customerId: '',
    };
  }

  render() {
    const { visible, customerId } = this.state;
    const { crmContactStore, contentStore, type } = this.props;
    const { remindInfo } = contentStore;
    // console.log(toJS(remindInfo))
    return (
      <div>
        <WeaDialog
          ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@p0dvmo`}
          style={{ width: 800, height: 500 }}
          visible={visible}
          title={getLabel(6082, '客户联系')}
          icon="icon-coms-crm"
          iconBgcolor="#96358a"
          buttons={this.getButtons()}
          onCancel={() => this.setVisible(false)}
        >
          <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@aahv1d`} height={'100%'} >
            <CustomerContact ecId={`${this && this.props && this.props.ecId || ''}_CustomerContact@jhkaxp`} contentStore={crmContactStore} params={{ from: 'base', customerId }} type={type} />
          </WeaNewScroll>
          <RemindSetModal ecId={`${this && this.props && this.props.ecId || ''}_RemindSetModal@1p4it9`} ref="remindSetInContact" remindInfo={toJS(remindInfo)} customerId={customerId} saveRemindSetting={this.saveRemindSetting} />
        </WeaDialog>
      </div>
    );
  }
  getButtons() {
    const { customerId } = this.state;
    const { contentStore } = this.props;
    const btn = [];
    btn.push(<Button
      ecId={`${this && this.props && this.props.ecId || ''}_Button@fcrkfh@contactRemindSet`}
      type="primary"
      onClick={() => {
        contentStore.getRemindInfo(customerId);
        this.refs.remindSetInContact.setContactVisible(true);
      }}
    >{getLabel(84369, '联系提醒设置')}</Button>);
    btn.push(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@ybaq6i@close`} onClick={() => this.setVisible(false)}>{getLabel(309, '关闭')}</Button>);
    return btn;
  }
    setVisible = (visible, customerId = '') => {
      this.setState({ visible, customerId });
    }
    saveRemindSetting=(params) => {
      const { contentStore } = this.props;
      contentStore.saveRemindSetting(params);
    }
}

export default CustomerContactDialog;
